 
 --Monta armazenado 
 
 SELECT  
   HISTORICO  = 'MAPA ARMAZENADO',   
   A.CODIGO_FILIAL,  
   A.DATA_FISCAL,   
   A.TERMINAL,     
   TOT_CF    = (A.CF_FINAL - A.CF_INICIAL) + 1,   
   A.TOTAL_BRUTO,      
   A.TOTAL_CANCELADO,   
   A.TOTAL_DESCONTO ,    
   A.TOTAL_ISENTO,    
   A.TOTAL_NAO_TRIBUTAVEL,   
   A.TOTAL_SUBSTITUICAO,    
   B.PER_TARIFA,   
   B.TOTAL_TARIFA,   
   A.CF_INICIAL,   
   A.CF_FINAL,  
   A.ECF,  
   A.ID_EQUIPAMENTO,  
   A.SERIE_NF,  
   B.LEGENDA_TARIFA    
  FROM   
   LOJA_CONTROLE_FISCAL A (NOLOCK)   
   JOIN LOJA_CONTROLE_FISCAL_TARIFAS B (NOLOCK) ON   
    A.CODIGO_FILIAL  = B.CODIGO_FILIAL  AND     
    A.DATA_FISCAL  = B.DATA_FISCAL  AND   
    A.TERMINAL  = B.TERMINAL  AND  
    A.ECF   = B.ECF   AND  
    A.ID_EQUIPAMENTO = B.ID_EQUIPAMENTO AND  
    A.SERIE_NF  = B.SERIE_NF  AND  
    A.CF_INICIAL  = B.CF_INICIAL        
  WHERE   
   A.DATA_FISCAL  = '20100528'  AND   
   A.CODIGO_FILIAL  = '000001' AND   
   A.TERMINAL   = '001'    AND  
   B.ID_IMPOSTO  = 1  